Skip to content

fix(ui): throttle self-serve SSO domain verification retries - #9275

Open
NicolasLopes7 wants to merge 7 commits into
mainfrom
nicolas/retry-sso-domain-verification
Open

fix(ui): throttle self-serve SSO domain verification retries#9275
NicolasLopes7 wants to merge 7 commits into
mainfrom
nicolas/retry-sso-domain-verification

Conversation

@NicolasLopes7

Copy link
Copy Markdown
Contributor

Summary

  • show the domain verification retry action while a self-serve SSO domain is pending or expired
  • throttle each domain retry for five minutes, including when a retrigger changes the domain from expired to pending
  • add coverage for retry visibility and cooldown behavior

Testing

  • pnpm --filter @clerk/ui exec vitest run src/components/ConfigureSSO/tests/ConfigureSSO.test.tsx
  • pnpm --filter @clerk/ui exec eslint src/components/ConfigureSSO/steps/OrganizationDomainsStep.tsx src/components/ConfigureSSO/tests/ConfigureSSO.test.tsx

@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 77081cd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages
Name Type
@clerk/ui Patch
@clerk/localizations Patch
@clerk/shared Patch
@clerk/astro Patch
@clerk/chrome-extension Patch
@clerk/react Patch
@clerk/swingset Patch
@clerk/vue Patch
@clerk/backend Patch
@clerk/clerk-js Patch
@clerk/electron Patch
@clerk/expo-passkeys Patch
@clerk/expo Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/headless Patch
@clerk/hono Patch
@clerk/msw Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview Aug 7, 2026 3:38pm
swingset Ready Ready Preview Aug 7, 2026 3:38pm

Request Review

@pkg-pr-new

pkg-pr-new Bot commented Jul 29, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@9275

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@9275

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@9275

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@9275

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@9275

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@9275

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@9275

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@9275

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@9275

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@9275

@clerk/express

npm i https://pkg.pr.new/@clerk/express@9275

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@9275

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@9275

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@9275

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@9275

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@9275

@clerk/react

npm i https://pkg.pr.new/@clerk/react@9275

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@9275

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@9275

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@9275

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@9275

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@9275

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@9275

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@9275

commit: 77081cd

@NicolasLopes7
NicolasLopes7 marked this pull request as ready for review July 29, 2026 18:39
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-08-07T15:39:53.583Z

Summary

Metric Count
Packages analyzed 19
Packages with changes 1
🔴 Breaking changes 0
🟡 Non-breaking changes 1
🟢 Additions 0

🤖 This report was reviewed by claude-sonnet-4-6.


@clerk/shared

Current version: 4.27.0
Recommended bump: MINOR → 4.28.0

Subpath ./types

🟡 Non-breaking Changes (1)

Modified: __internal_LocalizationResource
// ... 1344 unchanged lines elided ...
          expiredAtLabel: LocalizationValue<'date'>;
          expiredLabel: LocalizationValue;
          verifyAgainButton: LocalizationValue;
+         verifyAgainButtonTooltip__throttled: LocalizationValue;
          removeButtonTooltip__lastVerifiedDomain: LocalizationValue;
          removeButtonTooltip__lastVerifiedDomainActive: LocalizationValue;
          txtRecord: {
// ... 716 unchanged lines elided ...

Static analyzer: Breaking change in type alias __internal_LocalizationResource: Type changed: {locale:string;maintenanceMode:import("@clerk/shared").LocalizationValue;roles:{[r:string]:import("@clerk/shared").Loca…{locale:string;maintenanceMode:import("@clerk/shared").LocalizationValue;roles:{[r:string]:import("@clerk/shared").Loca…

🤖 AI review (reclassified as non-breaking) (70%): The type is consumed only through LocalizationResource extends DeepPartial<DeepLocalizationWithoutObjects<__internal_LocalizationResource>>, which makes all fields optional, so adding a new field to __internal_LocalizationResource does not require consumers to supply it.


Report generated by Break Check

Last ran on 77081cd.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

ConfigureSSO adds ownership-verification retries with a five-minute cooldown. Expired and unverified TXT-record states use a shared retry control. The control displays throttled-state messaging. Tests cover retry visibility, cooldown behavior, countdown messaging, failed requests, and timer restoration. Localization resources and a patch changeset document the behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • clerk/javascript#9356: Both changes modify OrganizationDomainsStep.tsx and ConfigureSSO.test.tsx around ownership-verification retry behavior.

Suggested reviewers: gabrielmeloc22, kalafut, laurabeatris

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description accurately summarizes retry visibility, five-minute throttling, test coverage, and the targeted validation commands.
Title check ✅ Passed The title clearly and concisely describes throttling self-serve SSO domain verification retries.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

Comment on lines +382 to +384
const retryTimerRef = useRef<number | undefined>(undefined);
const isVerificationRetryThrottledRef = useRef(false);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the thinking behind the use of useRef to store timeouts? I feel like useState might be more appropriate but I'd like to understand more

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude tripped here, just addressed

Drop the ref that mirrored the throttle flag: the click handler closes over
current state, and the button is already disabled while throttled.

Track the cooldown as a deadline instead of a boolean, start it only after
prepareOwnershipVerification resolves, and show the remaining time on the
disabled retry button. Move the retry action inline with the TXT record value.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/ui/src/components/ConfigureSSO/steps/OrganizationDomainsStep.tsx`:
- Around line 609-616: Add a dedicated element descriptor to
elementDescriptors.ts, then import and pass it via the elementDescriptor prop on
the retry Button in OrganizationDomainsStep. Keep the descriptor specific to
this retry control so it is available for Appearance customization.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 5d9cf024-57d0-48b8-8c5c-faa2fe1f4f19

📥 Commits

Reviewing files that changed from the base of the PR and between 8603802 and 791ee57.

📒 Files selected for processing (5)
  • .changeset/bright-trees-retry.md
  • packages/localizations/src/en-US.ts
  • packages/shared/src/types/localization.ts
  • packages/ui/src/components/ConfigureSSO/__tests__/ConfigureSSO.test.tsx
  • packages/ui/src/components/ConfigureSSO/steps/OrganizationDomainsStep.tsx
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go (manual)
  • clerk/dashboard (manual)
  • clerk/accounts (manual)
  • clerk/backoffice (manual)
  • clerk/clerk (manual)
  • clerk/clerk-docs (manual)
  • clerk/cloudflare-workers (manual)
  • clerk/clerk-ios (auto-detected)
  • clerk/cli (auto-detected)
  • clerk/clerk-android (auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/bright-trees-retry.md

Comment on lines +609 to +616
<Button
variant='bordered'
colorScheme='secondary'
size='xs'
isLoading={isVerifying}
isDisabled={isThrottled}
onClick={onClick}
sx={[t => ({ flexShrink: 0, gap: t.space.$1x5 }), sx]}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add an element descriptor for the retry button.

Line 609 creates a new themable Button without elementDescriptor. Add a dedicated descriptor in packages/ui/src/customizables/elementDescriptors.ts and pass it to this button. This keeps the new retry control customizable through Appearance configuration.

As per coding guidelines, “Use element descriptors for all themable elements by applying elementDescriptor prop to components and importing descriptors from packages/ui/src/customizables/elementDescriptors.ts.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/ui/src/components/ConfigureSSO/steps/OrganizationDomainsStep.tsx`
around lines 609 - 616, Add a dedicated element descriptor to
elementDescriptors.ts, then import and pass it via the elementDescriptor prop on
the retry Button in OrganizationDomainsStep. Keep the descriptor specific to
this retry control so it is available for Appearance customization.

Source: Coding guidelines

Build the retry button once in DomainCard and pass it down as a node,
mirroring the existing removeButton pattern, instead of drilling three
props through ExpiredNotice and TxtRecord.

Drop the live countdown so the cooldown needs a single setTimeout rather
than a per-second interval plus its derived-state mirror and formatter.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/ui/src/components/ConfigureSSO/steps/OrganizationDomainsStep.tsx (1)

86-95: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Do not throttle resolved domain-preparation failures.

The bulk API reports a failed domain in its resolved errors array. This helper returns true for every fulfilled request. DomainCard then disables retries for five minutes after a failed preparation.

Return false when the response contains an error for this one-domain request. Add coverage for a fulfilled response with errors.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/ui/src/components/ConfigureSSO/steps/OrganizationDomainsStep.tsx`
around lines 86 - 95, Update handlePrepareOwnershipVerification to inspect the
fulfilled prepareOwnershipVerification response and return false when its errors
array contains an error for the requested domain; return true only when
preparation succeeds without errors. Preserve existing catch handling and add
coverage for a fulfilled response containing errors.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/ui/src/components/ConfigureSSO/steps/OrganizationDomainsStep.tsx`:
- Around line 86-95: Update handlePrepareOwnershipVerification to inspect the
fulfilled prepareOwnershipVerification response and return false when its errors
array contains an error for the requested domain; return true only when
preparation succeeds without errors. Preserve existing catch handling and add
coverage for a fulfilled response containing errors.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: cbe87816-f26e-4ad5-b1c6-1e02e99b0a5d

📥 Commits

Reviewing files that changed from the base of the PR and between 791ee57 and 55e8d42.

📒 Files selected for processing (5)
  • .changeset/bright-trees-retry.md
  • packages/localizations/src/en-US.ts
  • packages/shared/src/types/localization.ts
  • packages/ui/src/components/ConfigureSSO/__tests__/ConfigureSSO.test.tsx
  • packages/ui/src/components/ConfigureSSO/steps/OrganizationDomainsStep.tsx
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go (manual)
  • clerk/dashboard (manual)
  • clerk/accounts (manual)
  • clerk/backoffice (manual)
  • clerk/clerk (manual)
  • clerk/clerk-docs (manual)
  • clerk/cloudflare-workers (manual)
  • clerk/clerk-ios (auto-detected)
  • clerk/cli (auto-detected)
  • clerk/clerk-android (auto-detected)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/localizations/src/en-US.ts
  • .changeset/bright-trees-retry.md
  • packages/ui/src/components/ConfigureSSO/tests/ConfigureSSO.test.tsx

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Adds the verifyAgainButtonTooltip__throttled placeholder to the other
locales, as the generate step requires.
The button calls prepare, which rotates the TXT challenge, while the UI
already polls attempt on its own. "Verify again" read as a manual check,
so clicking it while waiting on DNS silently invalidated the record the
admin had already published.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants